# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
 
@File:Yi5_0.py
@Time:2024/8/7 16:32

@Motto:不积跬步无以至千里，不积小流无以成江海！
"""
# 定义八卦的卦象（二进制表示，0为阴，1为阳）和名称
bagua = [
    ("000", "坤"),
    ("001", "艮"),
    ("010", "坎"),
    ("011", "巽"),
    ("100", "震"),
    ("101", "离"),
    ("110", "兑"),
    ("111", "乾")
]

# 定义六十四卦的名称列表
hexagram_names = [
    "乾为天", "泽天夬", "火天大有", "地天泰", "雷天大壮", "水天需", "山天大畜", "风天小畜",
    "天泽履", "地泽临", "风泽中孚", "雷泽归妹", "泽雷随", "泽火革", "泽山咸", "风山渐",
    "天山遁", "地山谦", "雷地豫", "泽地萃", "山地剥", "地雷复", "地泽临", "风泽中孚",
    "天泽履", "地泽临", "风泽中孚", "雷泽归妹", "泽雷随", "泽火革", "泽山咸", "风山渐",
    "天火同人", "地火明夷", "雷火丰", "泽火家人", "山火贲", "风火鼎", "天水讼", "地水师",
    "雷水解", "泽水困", "山水蒙", "风水涣", "天山遯", "地山升", "雷山小过", "泽山咸",
    "山泽损", "风泽中孚", "天雷无妄", "地雷豫", "雷雷震", "泽雷随", "山水蹇", "风山渐",
    "天风姤", "地风观", "雷风恒", "泽风益", "山风蛊", "风风巽","ddd","ddda"
]

# 由于我们已经定义了八卦和部分六十四卦的名称，我们可以使用相同的方法来生成完整的六十四卦列表
def generate_hexagrams():
    hexagrams = []
    # 遍历八卦作为上卦
    for upper in bagua:
        # 遍历八卦作为下卦
        for lower in bagua:
            # 组合上卦和下卦的卦象
            hexagram_image = upper[0] + lower[0]
            # 计算六十四卦的索引（从0开始）
            index = int(hexagram_image, 2)
            # 获取对应的六十四卦名称
            hexagram_name = hexagram_names[index]
            # 将卦象和卦名作为一个元组添加到列表中
            hexagrams.append((hexagram_image, hexagram_name))
    return hexagrams

# 生成六十四卦
hexagrams = generate_hexagrams()

# 打印六十四卦的卦象和卦名
for i, (image, name) in enumerate(hexagrams, 1):
    print(f"第{i}卦： {image} {name}")

